package com.travel.controller;

import com.travel.pojo.Hotel;
import com.travel.service.HotelService;
import com.travel.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/hotel")
public class HotelController {

    @Autowired
    private HotelService hotelService;

    @RequestMapping("/add")
    public Map<String, Object> add(Hotel hotel) {
        hotelService.add(hotel);
        return JsonResult.getSuccessResult("添加成功", hotel);
    }

    @RequestMapping("/update")
    public Map<String, Object> update(Hotel hotel) {
        hotelService.update(hotel);
        return JsonResult.getSuccessResult("修改成功", null);
    }

    @RequestMapping("/delete")
    public Map<String, Object> delete(Integer id) {
        hotelService.delete(id);
        return JsonResult.getSuccessResult("删除成功", null);
    }

    @RequestMapping("/list")
    public Map<String, Object> list(Hotel hotel, int pageNum, int pageSize) {
        return JsonResult.getSuccessResult("成功", hotelService.getList(hotel, pageNum, pageSize));
    }
}
